<?php use_helper('jQuery', 'I18N', 'Date') ?>
<?php $cliente = $form->getObject();?>
<div id="editar" title="<?php echo __("Datos del Cliente: ")?>
                          <?php echo $cliente->getNombre(); ?>
                          <?php echo $cliente->getPrimerApellido(); ?>
                          <?php echo $cliente->getSegundoApellido(); ?>
                       " class="contacto">
	<form action="<?php echo url_for('contacto/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" id="formNuevo" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
            <?php if (!$form->getObject()->isNew()): ?>
            <input type="hidden" name="sf_method" value="put" />
            <?php endif; ?>
            <?php echo $form->renderHiddenFields(false) ?> 
            <?php echo $form->renderGlobalErrors() ?>
            <?php include_partial('contacto/editaContacto',array('form'=> $form))?>
        </form>
</div>

<script language="JavaScript" type="text/javascript">
  	$(function() {
                var aceptar = function () {
			$('#formNuevo').submit();
  		};
  		var cancelar = function () {
  			$("#editar").dialog("destroy");
			$("#editar").remove();
                        <?php if ($sf_user->getAttribute('redirecPoliza')) : ?>
                            window.location = "<?php echo url_for('@poliza'); ?>";
                        <?php else : ?>
                            window.location = "<?php echo url_for('@contacto'); ?>";
                        <?php endif; ?>    
  		};
                //var eliminar = function () {
  		//	$("#editar").dialog("destroy");
		//	$("#editar").remove();
		//	window.location = "< ?php echo url_for('@contacto').'/delete/id/'.$form->getObject()->getId();?>";
  		//};

  		
  		var dialogOpts = {
  			autoOpen: true,
  			width:850,
  			minHeight:600,
  			closeOnEscape: true,
  			modal: true,
  			buttons: {
  	  			"<?php echo __("Guardar")?>": aceptar,
                                //"< ?php echo __("Eliminar")?>": eliminar,
  				"<?php echo __("Cancelar")?>": cancelar
                                
  			},
  			open: function() {
                                $(this).parent().find('button:nth-child(2)').focus();
                        },
                        resizable: false,
                        close: function() { location.href = "<?php echo url_for('@contacto'); ?>" }
  		};
  		$("#editar").dialog(dialogOpts);

  		
  	 
	});
  	
  </script>





